package com.atguigu.day04.HomeWork;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/3 17:20
 * @注释 打印空心菱形
 */
public class HomeWork4 {
    public static void main(String[] args) {
        //打印上半部分三角形
        for (int i = 1; i <= 5; i++) {
            //打印前面的空格
            for (int j = 5; j >= i; j--) {
                System.out.print("  ");
            }
            //打印九列*
            for (int j = 1; j <= 2 * i - 1; j++) {
                //在第一个位置和相对应位置放*, 其余位置放空格
                if (j == 1 || j == 2 * i - 1) {
                    System.out.print("* ");
                } else {
                    System.out.print("  ");
                }
            }
            System.out.println();
        }

        //打印下半部分三角形
        for (int i = 1; i <= 4; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("  ");
            }
            for (int j = 1; j <= (9 - 2 * i); j++) {
                if (j == 1 || j == 9 - 2 * i) {
                    System.out.print("* ");
                }else{
                    System.out.print("  ");
                }
            }
            System.out.println();
        }
    }
}
